#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
	vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
		unordered_set<int> result_set; // 存放结果，之所以用set是为了给结果集去重
		unordered_set<int> nums_set(nums1.begin(), nums1.end());
		for (int num : nums2) {
			// 发现nums2的元素 在nums_set里又出现过
			if (nums_set.find(num) != nums_set.end()) {
				result_set.insert(num);
			}
		}
		return vector<int>(result_set.begin(), result_set.end());
	}
};
class Test{
public:
	vector<int> intersection(vector<int>& num1,vector<int>& num2){
		unordered_set<int> result;
		unordered_set<int> num(num1.begin(),num1.end());
		for(int i = 0;i < num2.size();i++){
			if(num.find(num2[i]) != num.end()){
				result.insert(num2[i]);
			}	
		}
		return vector<int>(result.begin(),result.end());
	}
};

int main(){
	
	return 0;
}
